package gases.as3.testing
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	
	import gases.as3.debug.DebugBase;
	import gases.as3.librarys.compnents.resource.MacroResourceManagaers;
	import gases.as3.librarys.compnents.skin.SkinStylesMangaer;
	import gases.as3.librarys.compnents.skin.SkinTransform;
	import gases.as3.librarys.compnents.skin.data.BaseSkin;
	import gases.as3.librarys.compnents.skin.transform.TransformXML;
	import gases.as3.librarys.compnents.ui.container.GPanel;
	import gases.as3.librarys.compnents.ui.container.GTitle;
	
	public class TestingGPanel extends DebugBase
	{
		public function TestingGPanel()
		{
			super();
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;

			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.load(new URLRequest("assets/panelSkin.swf"));
		}
		
		private function onComplete(e:Event):void
		{
			var swf:DisplayObject = LoaderInfo(e.target).content as DisplayObject;
			MacroResourceManagaers.instance.UIResManager.setUISkinSwf(swf);
			var transform:SkinTransform = new SkinTransform();
			transform.setConfigTransform(new TransformXML());
			transform.resloveSkinConfig(panelXML);
			transform.resloveSkinConfig(titleXML);
			
			var panelSkin:BaseSkin = SkinStylesMangaer.instance.getSkinData("panel_image") as BaseSkin;
			var titleSkin:BaseSkin = SkinStylesMangaer.instance.getSkinData("title_image") as BaseSkin;
//			var content:DisplayObject = LoaderInfo(e.target).content;
//			bmd = (content as Bitmap).bitmapData ;
			
			_panel = new GPanel(400,300); 
			_panel.x =100;
			_panel.skin = panelSkin;
			this.addChild(_panel);
			_title = new GTitle(400,25,"hello world",0x000000); 
			
			_title.skin = titleSkin;
			_panel.addChild(_title);
			
		}
		
		private var panelXML:XML = <root>
									<skin type="panel" scale9_top="5" scale9_left="5" scale9_right="5" scale9_bottom="5" skinname="panel_image" width="60" height="20">
										<styles stylesName="background" resName="panel_background"/>
									</skin>
						 	</root>;
		private var titleXML:XML = <root>
											<skin type="panel" scale9_top="5" scale9_left="5" scale9_right="5" scale9_bottom="5" skinname="title_image" width="60" height="20">
												<styles stylesName="title_background" resName="title_background"/>
											</skin>
									</root>;
		private var _panel:GPanel;
		private var _title:GTitle;
		private var bmd:Object ;
	}
}